package cloud.xlh.my_system.service.impl;

import cloud.xlh.my_system.common.response.Response;
import cloud.xlh.my_system.mapper.UserMapper;
import cloud.xlh.my_system.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cloud.xlh.my_system.pojo.User;
import javax.transaction.Transactional;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : code-generator
 * @ Author: XuLeHuang
 * @ Date: 2022/5/30 17:18
 * @ Description:
 */
@Service
@Transactional
public class LoginServiceImpl implements LoginService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Response<String> doLogin(HashMap hashMap) {
        String name = (String) hashMap.get("name");
        String password = (String) hashMap.get("password");
        //用户名+密码查找用户
        User isExist = userMapper.findByNameAndPassword(name , password);
        if (isExist == null) {
            return Response.error("登陆失败，请检查账号密码！");
        }
        return Response.success("登陆成功！");
    }
}
